a2b4c88ef4b0f53990e552365a5b1474e173b292,testbench/tests/jetbrains/mps/repo/RepoListenerTest.java,RepoListenerTest,testGlobalAttach,#,123

Before Change


    //
    final AttachRepoListener l2 = new AttachRepoListener();
    SRepositoryRegistry.getInstance().addGlobalListener(l2);
    l1.checkStarted(2);
    l1.checkStopped(0);
    l2.checkStarted(2); // == that of l1 starts to the date, == amount of our available repositories
    l2.checkStopped(0);
    SRepositoryRegistry.getInstance().removeGlobalListener(l2);
    l1.checkStarted(2);
    l1.checkStopped(0); // l1 is not notified on l2 removal
    l2.checkStarted(2);
    l2.checkStopped(2); // l2 is removed from both available repositories, global+project
    //
    closeProject();
    l1.checkStarted(2);
    l1.checkStopped(1); // project repo is gone, 1 notification
    l2.checkStarted(2); // l2 is detached, shall not get any further notifications
    l2.checkStopped(2);
    SRepositoryRegistry.getInstance().removeGlobalListener(l1);
    l1.checkStarted(2);
    l1.checkStopped(2); // notified for global repo
    l2.checkStarted(2); // l2 is detached, shall not get any further notifications
    l2.checkStopped(2);
  }

  /**

After Change


    l1.checkStopped(0);
    createProject();
    // project repo mimics global repo now, listener is attached only once, hence we observe events of 1 repository instead of 2.
    final int distinctRepositories = 1; // FIXME =2 once ProjectRepository is distinct from global (or there's no global?)
//    l1.checkStarted(2); // global + project repo
    l1.checkStarted(distinctRepositories);
    l1.checkStopped(0);
    //
    final AttachRepoListener l2 = new AttachRepoListener();
    SRepositoryRegistry.getInstance().addGlobalListener(l2);
    l1.checkStarted(distinctRepositories);
    l1.checkStopped(0);
    l2.checkStarted(distinctRepositories); // == that of l1 starts to the date, == amount of our available repositories
    l2.checkStopped(0);
    SRepositoryRegistry.getInstance().removeGlobalListener(l2);
    l1.checkStarted(distinctRepositories);
    l1.checkStopped(0); // l1 is not notified on l2 removal
    l2.checkStarted(distinctRepositories);
    l2.checkStopped(distinctRepositories); // l2 is removed from both available repositories, global+project
    //
    closeProject();
    l1.checkStarted(distinctRepositories);
    l1.checkStopped(distinctRepositories-1); // project repo is gone, 1 notification
    l2.checkStarted(distinctRepositories); // l2 is detached, shall not get any further notifications
    l2.checkStopped(distinctRepositories); // --"--
    SRepositoryRegistry.getInstance().removeGlobalListener(l1);
    l1.checkStarted(distinctRepositories);
    l1.checkStopped(distinctRepositories); // notified for global repo